/**
 * 
 */
package server.connection.protocol;

/**
 * Class representing incoming and outcoming events.
 * 
 * @author Kamil Nowak
 * 
 */
public class Event {
	
	private EventType type;
	private String[] params;
	private Long connectionId;
	
	/**
	 * Returns connection that sent event or event is going to be send to
	 * @return
	 */
	public Long getConnectionId() {
		return connectionId;
	}

	/**
	 * Creates new event
	 * @param type type of a message
	 * @param params event parameters
	 */
	public Event(EventType type,String[] params) {
		
		this.params = params;
		this.type = type;
	}
	
	
	
	/**
	 * Creates new event.
	 * @param type type of a message
	 * @param params event parameters
	 * @param connectionId connectionId event came from / is sending to
	 */
	public  Event(EventType type, String[] params,  Long connectionId ) {
		this.connectionId = connectionId;
		this.params = params;
		this.type = type;
	}
	public Event() {
	}
	
	public String[] getParams() {
		return params;
	}
	public EventType getType() {
		return type;
	}
	public void setParams(String[] params) {
		this.params = params;
	}
	public void setType(EventType type) {
		this.type = type;
	}
	public void setConnectionId(Long connectionId) {
		this.connectionId = connectionId;
	}

	@Override
	public String toString() {
		StringBuffer str = new StringBuffer();
		for (String cc : params) {
			str.append(cc).append("|");
		}
		
		return new StringBuffer("type: ").append(type.toString()).append(" params: ").append(str).
		append(" connectionId: ").append(connectionId).toString();
	}	
	
	

}
